package com.phone580.app.login;

import java.io.IOException;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import android.content.Context;

import com.phone580.app.BaseTask;
import com.phone580.app.CommonData;
import com.phone580.app.entity.LogoutEntity;
import com.phone580.app.model.LogoutModel;
import com.phone580.app.net.HttpAccess;

public class LogoutTask extends BaseTask {

	public LogoutTask(Context context) {
		super(context);
	}

	@Override
	public void setParams(Object... params) {

	}
	
	@Override
	protected void onPreExecute() {
		showDialog("正在注销，请稍后...", false);
	}

	@Override
	protected Object doInBackground(Void... params) {
		try {
			String result = HttpAccess.doGet(CommonData.LOGOUT_URL);
			LogoutModel model = new LogoutModel();
			LogoutEntity  entity = model.parseLogout(result.trim());
			CommonData.login = null;
			return entity;
		} catch (ClientProtocolException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		}
		return null;
	}

}
